package com.mx.restful.annotation;

import com.mx.restful.beans.HttpMethod;
import org.jetbrains.annotations.Nullable;

/**
 * @Author: mengxiang.
 * @Date: 2020/6/22.
 * @Time: 11:37 上午.
 * @Description:
 */
public enum HttpMethodAnnotation {

    /**
     * RequestMapping
     */
    REQUEST_MAPPING("net.ymate.platform.webmvc.annotation.RequestMapping", HttpMethod.REQUEST),

    /**
     * spring RequestMapping
     */
    /**
     * RequestMapping
     */
    SPRING_REQUEST_MAPPING("org.springframework.web.bind.annotation.RequestMapping", HttpMethod.REQUEST),

    /**
     * GetMapping
     */
    SPRING_GET_MAPPING("org.springframework.web.bind.annotation.GetMapping", HttpMethod.GET),

    /**
     * PostMapping
     */
    SPRING_POST_MAPPING("org.springframework.web.bind.annotation.PostMapping", HttpMethod.POST),

    /**
     * PutMapping
     */
    SPRING_PUT_MAPPING("org.springframework.web.bind.annotation.PutMapping", HttpMethod.PUT),

    /**
     * DeleteMapping
     */
    SPRING_DELETE_MAPPING("org.springframework.web.bind.annotation.DeleteMapping", HttpMethod.DELETE),

    /**
     * PatchMapping
     */
    SPRING_PATCH_MAPPING("org.springframework.web.bind.annotation.PatchMapping", HttpMethod.PATCH),

    /**
     * RequestParam
     */
    SPRING_REQUEST_PARAM("org.springframework.web.bind.annotation.RequestParam", null),

    /**
     * RequestParam
     */
    REQUEST_PARAM("net.ymate.platform.webmvc.annotation.RequestParam", null);



    private final String qualifiedName;
    private final HttpMethod method;

    HttpMethodAnnotation(String qualifiedName, HttpMethod method) {
        this.qualifiedName = qualifiedName;
        this.method = method;
    }

    @Nullable
    public static HttpMethodAnnotation getByQualifiedName(String qualifiedName) {
        for (HttpMethodAnnotation springRequestAnnotation : HttpMethodAnnotation.values()) {
            if (springRequestAnnotation.getQualifiedName().equals(qualifiedName)) {
                return springRequestAnnotation;
            }
        }
        return null;
    }

    public HttpMethod getMethod() {
        return this.method;
    }

    public String getQualifiedName() {
        return qualifiedName;
    }




}